package com.luna.serviceImpl;

import com.luna.beans.Phase;
import com.luna.dao.PhaseDao;
import com.luna.service.PhaseService;

import java.util.List;

public class PhaseServiceImpl implements PhaseService {
    @Override
    public List<Phase> phaseListInBook(int book_id) {
        List<Phase> list = null;
        PhaseDao phaseDao = new PhaseDao();
        try {
            list = phaseDao.selectAllPhaseByBookId(book_id);
        } catch (Exception ignored) {}
        return list;
    }

    @Override
    public boolean addPhase(Phase phase) {
        PhaseDao phaseDao = new PhaseDao();
        try {
            phaseDao.insertPhase(phase);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }

    @Override
    public boolean dropPhase(int phase_id) {
        PhaseDao phaseDao = new PhaseDao();
        try {
            phaseDao.dropPhaseById(phase_id);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }

    @Override
    public boolean updatePhase(int phase_id, Phase phase) {
        PhaseDao phaseDao = new PhaseDao();
        try {
            phaseDao.updatePhase(phase_id, phase);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }
}
